package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportAnnounceDto;
import com.yqg.protection.entity.Announce;
import com.yqg.protection.mapper.AnnounceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/24 11:23
 * description:
 */
@Component
public class AnnounceListener extends AnalysisEventListener<ImportAnnounceDto> {

    @Autowired
    private AnnounceMapper announceMapper;

    @Override
    public void invoke(ImportAnnounceDto importAnnounceDto, AnalysisContext analysisContext) {
        Announce announce = new Announce();
        BeanUtil.copyProperties(importAnnounceDto, announce, true);
        announceMapper.insert(announce);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
